package com.yuan.java.reflect.proxy;

import org.junit.Test;

import java.lang.reflect.Proxy;

/**
 * @author yuaneg 2018/12/12
 */
public class TestProxy {

    @Test
    public void proxyTest() throws ClassNotFoundException, InstantiationException, IllegalAccessException {
        MethodProxy invocationHandler = new MethodProxy("aaa",new ProTestImpl());
        Object newProxyInstance = Proxy.newProxyInstance(ProxyTest.class.getClassLoader(), new Class[]{ProxyTest.class}, invocationHandler);
        ProxyTest tt = (ProxyTest) newProxyInstance;
        System.out.println(tt.aaa());
        System.out.println(tt.bbb());
        System.out.println(tt.noPro());
    }

}
